<?php

/**
 * This is the model class for table "auftrag".
 *
 * The followings are the available columns in table 'auftrag':
 * @property integer $auftragsID
 * @property string $dauer
 * @property string $datum
 * @property integer $fahrzeug
 * @property integer $fahrer
 * @property string $startort
 * @property string $zeit
 * @property string $endort
 * @property integer $buchung
 */
class Auftrag extends CActiveRecord
{
	/**
	 * Returns the static model of the specified AR class.
	 * @return Auftrag the static model class
	 */
	public static function model($className=__CLASS__)
	{
		return parent::model($className);
	}

	/**
	 * @return string the associated database table name
	 */
	public function tableName()
	{
		return 'auftrag';
	}

	/**
	 * @return array validation rules for model attributes.
	 */
	public function rules()
	{
		// NOTE: you should only define rules for those attributes that
		// will receive user inputs.
		return array(
			array('dauer, datum, fahrzeug, fahrer, startort, zeit, endort, buchung', 'required'),
			array('fahrzeug, fahrer, buchung', 'numerical', 'integerOnly'=>true),
			array('dauer, datum, startort, zeit, endort', 'length', 'max'=>100),
			// The following rule is used by search().
			// Please remove those attributes that should not be searched.
			array('auftragsID, dauer, datum, fahrzeug, fahrer, startort, zeit, endort, buchung', 'safe', 'on'=>'search'),
		);
	}

	/**
	 * @return array relational rules.
	 */
	public function relations()
	{
		// NOTE: you may need to adjust the relation name and the related
		// class name for the relations automatically generated below.
		return array(
		);
	}

	/**
	 * @return array customized attribute labels (name=>label)
	 */
	public function attributeLabels()
	{
		return array(
			'auftragsID' => 'Auftrags',
			'dauer' => 'Dauer',
			'datum' => 'Datum',
			'fahrzeug' => 'Fahrzeug',
			'fahrer' => 'Fahrer',
			'startort' => 'Startort',
			'zeit' => 'Zeit',
			'endort' => 'Endort',
			'buchung' => 'Buchung',
		);
	}

	/**
	 * Retrieves a list of models based on the current search/filter conditions.
	 * @return CActiveDataProvider the data provider that can return the models based on the search/filter conditions.
	 */
	public function search()
	{
		// Warning: Please modify the following code to remove attributes that
		// should not be searched.

		$criteria=new CDbCriteria;

		$criteria->compare('auftragsID',$this->auftragsID);
		$criteria->compare('dauer',$this->dauer,true);
		$criteria->compare('datum',$this->datum,true);
		$criteria->compare('fahrzeug',$this->fahrzeug);
		$criteria->compare('fahrer',$this->fahrer);
		$criteria->compare('startort',$this->startort,true);
		$criteria->compare('zeit',$this->zeit,true);
		$criteria->compare('endort',$this->endort,true);
		$criteria->compare('buchung',$this->buchung);

		return new CActiveDataProvider(get_class($this), array(
			'criteria'=>$criteria,
		));
	}
}